package com.example.recall_application.utils;

import android.content.Context;
import android.net.Uri;
import android.os.Handler;
import android.provider.ContactsContract;
import android.text.TextUtils;

import java.util.ArrayList;
import java.util.List;

public final class SimHelper extends ResolverHelperImpl<List<String>> {

    public SimHelper(Context context, Handler handler,String condition) {
        super(context, handler,condition);
        mData = new ArrayList<>();
    }

    @Override
    protected void initParams() {
        contentUri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;

        mColumns = new String[]{
                ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,/*姓名*/
                ContactsContract.CommonDataKinds.Phone.NUMBER/*号码*/
        };
    }

    @Override
    protected void parseData() {
        while (mCursor != null && mCursor.moveToNext()) {
            String phone = mCursor.getString(mCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
            if (!TextUtils.isEmpty(phone)) {
                try {
                    mData.add(phone);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }

    @Override
    protected int getMsgWhat() {
        return 100003;
    }
}










































